package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/8/13 10:07
 * @apiNote
 */

public class Test00806NumberOfLines {
    public int[] numberOfLines(int[] widths, String s) {
        int lines = 1,chars = 0;
        for (char c : s.toCharArray()) {
            if(chars + widths[c - 'a'] > 100){
                lines ++;
                chars = widths[c - 'a'];
            }else{
                chars += widths[c - 'a'];
            }
        }
        return new int[]{lines, chars};
    }
}
